#ifndef __DWARF2_PANO_H__
#define __DWARF2_PANO_H__
#include <filesystem>

#include <opencv.hpp>

#include "panorama_base.h"
#include "autoresetevent.h"
#include "../motioncontrol/step_motor_user.h"
#include "../camera/cam_tele.h"

#include "panorama.pb.h"
#include "album.h"
#include "rgb_power.h"

class Dwarf2Panorama : public PanoramaBase {
public:

	constexpr const static double YawPerStep = 2.544;
	constexpr const static double PitchPerStep = 1.432;
	constexpr const static double YawSpeed = 15;
	constexpr const static double PitchSpeed = 15;
	constexpr const static int YawResolutionLevel = STEP_MOTOR_MINISTEP_32;
	constexpr const static int PitchResolutionLevel = STEP_MOTOR_MINISTEP_32;
	constexpr const static int YawRampPlus = STEP_MOTOR_RAMP_PULSE_800;
	constexpr const static int PitchRampPlus = STEP_MOTOR_RAMP_PULSE_800;

	Dwarf2Panorama(StepMotorUser* yaw_moto, StepMotorUser* pitch_moto, CamTele* cam);
	Dwarf2Panorama(){
		
	}
	int CapturePanoramaImages(std::string save_path, int rows, int cols, PanoramaInfoBase& out) override;
	int StopPanoramaCapture();
	int handleMessage(WsPacket& ws_packet);
	int notifiyPhotoProgress();

protected:
	void SetCurrentState(PanoramaState state) override{
		PanoramaBase::SetCurrentState(state);
		switch (state)
		{
		case PanoramaState::IDEL:
			_cam->setPanoramaState(CAM_PANORAMA_IDLE);
			break;
		case PanoramaState::Running:
			_cam->setPanoramaState(CAM_PANORAMA_PHOTOGRAPHING);
		default:
			break;
		}
	}
private:
	StepMotorUser* _yaw_moto = 0;
	StepMotorUser* _pitch_moto = 0;

	CamTele* _cam = 0;

	static std::string ToSpecifyDigit(unsigned int num,unsigned int digit){
		std::string num_s = std::to_string(num);
		while(num_s.length() < digit){
			num_s = "0" + num_s;
		}
		return num_s;
	}

	Album m_album_;
	RgbPower rgb_power_;

};
#endif